package java8Test.function.lambda.part2;

import spring.po.User;

import java.util.function.Consumer;

/**
 * @author : yang.xp
 * @date : 2022/9/22 17:35
 * @description : 消费对象，对对象进行操作，但是不返回值
 */
public class ConsumerTest<T> {

    // 后边的t实际上是类型推测
    private static Consumer<User> consumerUser1 = t -> t.setAge(t.getAge() + 1);
    // 需要制定泛型
    private static Consumer<Integer> consumerUser2 = t -> t += t;

    public static void main(String[] args) {
        User user = User.buildUser();
        consumerUser1.accept(user);
        System.out.println(user);
        consumerUser1.andThen(consumerUser1).accept(user);
        System.out.println(user);
    }
}
